(define-module (grump texconv)
  #:use-module (ice-9 ftw)
  #:use-module (ice-9 regex))

(define tex-file?
  (let* ((extensions '("chrbnd" "ffxbnd" "fgbnd" "objbnd" "partsbnd" "tpf" "tpfbhd"))
         (pattern (string-append "\\.(" (string-join extensions "|") ")(\\.dcx)?$")))
    (lambda (filename)
      (if (string-match pattern filename) #t #f))))

(define (for-each-tex-file path func)
  (ftw path (lambda (filename statinfo flag)
              (when (and (eq? flag 'regular)
                         (tex-file? filename))
                (func filename statinfo))
              #t)))

;; necessary formats:
;;  - DCX
;;  - TPF
;;  - BDT
;;  - BND
